#!/bin/bash

# 切换到脚本所在目录
cd "$(dirname "$0")"

# 设置 JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

# 编译 Java 类并生成 JNI 头文件
javac ExampleClass.java
javac -h . ExampleClass.java

# 编译 C 代码生成共享库
gcc -shared -fpic -o libexample.so -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux example.c

echo "Build completed successfully."